
  let url = window.location.href
  const getOpenId = () => {
    window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx86a236571c7eae9f&redirect_uri=http%3A%2F%2Fgzzlapitest.chudaokeji.com%2Foauth%2Fcallback.html&response_type=code&scope=snsapi_userinfo&state=${encodeURIComponent(url)}#wechat_redirect`
  }
  const getQueryString = (name) => {
    var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i')
    var r = window.location.search.substr(1).match(reg)
    if (r != null) {
      return unescape(decodeURIComponent(r[2]))
    }
    return null
  }
  let urlOpenId = getQueryString('openId') || ''
  let localOpenId = window.localStorage.openId || ''
  if (urlOpenId || localOpenId) {
    let openId = getQueryString('openId') || ''
    let nickName = getQueryString('nickName') || ''
    let headUrlImg = getQueryString('headUrlImg') || ''
    // console.log(openId, nickName, headUrlImg)
    // 本地没有时存储微信头像和昵称
    if (!window.localStorage.openId) {
      window.localStorage.openId = openId
    }
    if (!window.localStorage.nickName) {
      window.localStorage.nickName = nickName
    }
    if (!window.localStorage.headUrlImg) {
      window.localStorage.headUrlImg = headUrlImg
    }
  } else {
    getOpenId()
  }
